<!-- 推送虚拟组织目录 -->
<template>
</template>

<script>
import selectDepartment from '@/components/upCascadeInformation/selectDepartment.vue'
export default {
  data() {
    return {
      form: {},
      orgList: [], // 需要推送的部门id
      dialogVisible: false,
      successfulCallback: null
    }
  },
  components: {
    selectDepartment
  },
  // computed: {},
  mounted() {},
  // created(){ // document.title = this.type === 2 ? '设置手机号' : '绑定手机号' },
  methods: {
    async getOrgList() {
      const res = await this.$api.findAll('northPlatform/orgCatalog', {
        northPlatformId: this.form.id // 向上级联平台id
      })
      if (res.code === 200) {
        this.orgList = res.data || [] // 需要推送的部门id
        this.dialogVisible = true
      }
    },
    setOrgList(orgList = []) {
      this.orgList = orgList // 需要推送的部门id
    },
    show(item) {
      return new Promise((resolve, reject) => {
        this.successfulCallback = resolve
        this.form = { ...item }
        this.getOrgList()
      })
    },
    async onSubmit() {
      const orgCatalogPush = this.form.orgCatalogPush
      if (orgCatalogPush === 1 && this.orgList.length === 0) {
        return this.$message.error(
            this.$t('youHaveNotSelectedTheOrganizationToPush')
        )
      }
      const res = await this.$api.northPlatform.orgCatalogSave({
        northPlatformId: this.form.id, // 向上级联平台id
        orgCatalogPush: orgCatalogPush, // 是否推送虚拟组织目录（0否、1是）
        orgIdList: orgCatalogPush === 1 ? this.orgList.map((v) => v.id) : []
      })
      if (res.code === 200) {
        this.$message.success(this.$t('operationSuccessful'))
        this.successfulCallback(this.form)
        this.onClose()
      }
    },
    onClose() {
      this.dialogVisible = false
    }
  }
}
</script>
<style scoped lang="less" rel="stylesheet/less">
div#driver-popover-item {
  display: none;
  position: absolute;
  margin: 0;
  padding: 14px 14px 14px 28px;
  border-radius: 5px;
  min-width: 250px;
  max-width: 300px;
  min-height: 174px;
  z-index: 1000000000;
  color: var(--hy-text-main);
  border: 1px solid var(--theme);
  background: var(--background);
  box-shadow: 0 0 10px 4px var(--backgroundv2);
  //display: flex !important;
  flex-direction: column;
  box-sizing: border-box;
}
div#driver-popover-item .driver-popover-tip {
  border: 5px solid var(--theme);
  content: '';
  position: absolute;
}
div#driver-popover-item .driver-popover-tip.bottom {
  bottom: -10px;
  border-color: var(--theme) transparent transparent;
}
div#driver-popover-item .driver-popover-tip.bottom.position-center {
  left: 49%;
}
div#driver-popover-item .driver-popover-tip.bottom.position-right {
  right: 20px;
}
div#driver-popover-item .driver-popover-tip.left {
  left: -10px;
  top: 10px;
  border-color: transparent var(--theme) transparent transparent;
}
div#driver-popover-item .driver-popover-tip.left.position-center {
  top: 46%;
}
div#driver-popover-item .driver-popover-tip.left.position-bottom {
  top: auto;
  bottom: 20px;
}
div#driver-popover-item .driver-popover-tip.right {
  right: -10px;
  top: 10px;
  border-color: transparent transparent transparent var(--theme);
}
div#driver-popover-item .driver-popover-tip.right.position-center {
  top: 46%;
}
div#driver-popover-item .driver-popover-tip.right.position-bottom {
  top: auto;
  bottom: 20px;
}
div#driver-popover-item .driver-popover-tip.top {
  top: -10px;
  border-color: transparent transparent var(--theme);
}
div#driver-popover-item .driver-popover-tip.top.position-center {
  left: 49%;
}
div#driver-popover-item .driver-popover-tip.top.position-right {
  right: 20px;
}
div#driver-popover-item .driver-popover-tip.mid-center {
  display: none;
}
div#driver-popover-item .driver-popover-footer {
  display: block;
  margin-top: 10px;
}
div#driver-popover-item .driver-popover-footer button {
  &:active {
    opacity: 0.6;
  }
  background: var(--background);
  color: #ffffff;
  border: 1px solid var(--auxiliary);
  border-radius: 4px;
  font-size: 12px;

  display: inline-block;
  padding: 3px 10px;
  text-decoration: none;
  font: 11px / normal sans-serif;
  cursor: pointer;
  outline: 0;
  zoom: 1;
  line-height: 1.3;
  letter-spacing: 1px;
}
.first-step-class {
  .driver-prev-btn {
    display: none !important;
  }
}
div#driver-popover-item .driver-popover-footer button.driver-disabled {
  color: var(--info);
  border: 1px solid var(--info);
  cursor: not-allowed;
}
div#driver-popover-item .driver-popover-footer .driver-close-btn {
  color: var(--auxiliary);
  border: 0px solid var(--info);
  padding: 3px 0px;
  float: left;
  letter-spacing: 2px;
}
div#driver-popover-item .driver-popover-footer .driver-btn-group,
div#driver-popover-item .driver-popover-footer .driver-close-only-btn {
  float: right;
}
div#driver-popover-item .driver-popover-title {
  &::after {
    content: '';
    position: absolute;
    width: 4px;
    height: calc(100% - 4px);
    top: 50%;
    left: -12px;
    transform: translateY(-50%);
    background: var(--theme);
    border-radius: 2px;
  }
  font: 19px / normal sans-serif;
  margin: 0 0 5px;
  display: block;
  position: relative;
  zoom: 1;
  font-size: 14px;
  font-weight: bold;
  color: var(--main);
}
div#driver-popover-item .driver-popover-description {
  box-sizing: border-box;
  margin-bottom: 0;
  font: 14px / normal sans-serif;
  line-height: 1.5;
  font-size: 14px;
  color: var(--main);
  zoom: 1;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  div.content {
    flex-grow: 1;
  }
  ul {
    padding: 4px 0;
    li {
      &.select {
        background: var(--theme);
      }
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--theme-05);
      margin: 0 4px;
    }
  }
}
.driver-clearfix:after,
.driver-clearfix:before {
  content: '';
  display: table;
}
.driver-clearfix:after {
  clear: both;
}
.driver-stage-no-animation {
  -webkit-transition: none !important;
  -moz-transition: none !important;
  -ms-transition: none !important;
  -o-transition: none !important;
  transition: none !important;
  background: transparent !important;
  outline: 5000px solid rgba(0, 0, 0, 0.75);
}
div#driver-page-overlay {
  background: #000;
  position: fixed;
  bottom: 0;
  right: 0;
  display: block;
  width: 100%;
  height: 100%;
  zoom: 1;
  filter: alpha(opacity=75);
  opacity: 0.75;
  z-index: 100002 !important;
}
div#driver-highlighted-element-stage,
div#driver-page-overlay {
  top: 0;
  left: 0;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -ms-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
}
div#driver-highlighted-element-stage {
  position: absolute;
  height: 50px;
  width: 300px;
  background: #fff;
  z-index: 100003 !important;
  display: none;
  border-radius: 2px;
}
.driver-highlighted-element {
  z-index: 100004 !important;
}
.driver-position-relative {
  position: relative !important;
}
.driver-fix-stacking {
  z-index: auto !important;
  opacity: 1 !important;
  -webkit-transform: none !important;
  -moz-transform: none !important;
  -ms-transform: none !important;
  -o-transform: none !important;
  transform: none !important;
  -webkit-filter: none !important;
  -moz-filter: none !important;
  -ms-filter: none !important;
  -o-filter: none !important;
  filter: none !important;
  -webkit-perspective: none !important;
  -moz-perspective: none !important;
  -ms-perspective: none !important;
  -o-perspective: none !important;
  perspective: none !important;
  -webkit-transform-style: flat !important;
  -moz-transform-style: flat !important;
  -ms-transform-style: flat !important;
  transform-style: flat !important;
  -webkit-transform-box: border-box !important;
  -moz-transform-box: border-box !important;
  -ms-transform-box: border-box !important;
  -o-transform-box: border-box !important;
  transform-box: border-box !important;
  will-change: unset !important;
}

</style>
